package com.lpf.MyGameSaveBackup.utils;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import lombok.Data;

import java.util.List;
import java.util.Map;

/**
 * @desc: HttpCilentUtil 请求响应实体
 * @since: 2024/5/17
 * @Author: peifenglu
 */
//请求响应实体
@Data
public class ResponseVo {

    //请求地址
    private String reqUrl;

    //请求头
    private Map<String, List<String>> reqHeader;

    //请求入参
    private Map<String,Object> reqBody;

    //响应头
    private Map<String, List<String>> resHeader;

    //响应内容
    private String resBody;

    //响应状态码
    private Integer resStatus;

    //响应内容 根据clazz转换为对应实体，不传clazz 为空
    private Object resObj;


    public String getReqHeader(String name){
        if (StrUtil.isBlank(name)) {
            return null;
        } else {
            List<String> headerList = this.reqHeader.get(name.trim());
            return CollectionUtil.isEmpty(headerList) ? null : (String)headerList.get(0);
        }
    }

    public String getResHeader(String name){
        if (StrUtil.isBlank(name)) {
            return null;
        } else {
            List<String> headerList = this.resHeader.get(name.trim());
            return CollectionUtil.isEmpty(headerList) ? null : (String)headerList.get(0);
        }
    }

}
